package com.edu.exam.enums.assessment;

/**
 * 试卷检查规则类型枚举
 */
public enum PaperCheckRuleType {
    FORMAT("FORMAT", "格式检查"),
    CONTENT("CONTENT", "内容检查"),
    STRUCTURE("STRUCTURE", "结构检查"),
    COMPLETENESS("COMPLETENESS", "完整性检查"),
    ACCURACY("ACCURACY", "准确性检查"),
    CONSISTENCY("CONSISTENCY", "一致性检查"),
    VALIDATION("VALIDATION", "验证检查"),
    SECURITY("SECURITY", "安全检查"),
    QUALITY("QUALITY", "质量检查");

    private final String code;
    private final String description;

    PaperCheckRuleType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static PaperCheckRuleType fromCode(String code) {
        for (PaperCheckRuleType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown PaperCheckRuleType code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果描述无效
     */
    public static PaperCheckRuleType fromDescription(String description) {
        for (PaperCheckRuleType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown PaperCheckRuleType description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}